package cn.tedu.psychology.controller;

import cn.tedu.psychology.pojo.dto.QuestionAddNewDTO;
import cn.tedu.psychology.pojo.vo.QuestionListItemVO;
import cn.tedu.psychology.pojo.vo.QuestionStandardVO;
import cn.tedu.psychology.service.IQuestionService;
import cn.tedu.psychology.web.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "问题咨询模块")
@RestController
@RequestMapping("/questions")
public class QuestionController {

    @Autowired
    private IQuestionService questionService;

    @ApiOperation("添加问题")
    @PostMapping("/add-new")
    public JsonResult addNew(QuestionAddNewDTO questionAddNewDTO) {
        questionService.addNew(questionAddNewDTO);
        return JsonResult.ok();
    }

    @ApiOperation("问题详情")
    @GetMapping("{id:[0-9]+}")
    public JsonResult addNew(@PathVariable Long id) {
        QuestionStandardVO questionStandardVO = questionService.getStandardById(id);
        return JsonResult.ok(questionStandardVO);
    }

    @ApiOperation("问题列表")
    @GetMapping("")
    public JsonResult list() {
        List<QuestionListItemVO> list = questionService.list();
        return JsonResult.ok(list);
    }

}
